import request from "@/utils/request";

/**
 * 新增角色
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export function createRole(data) {
    return request({
        url: '/sys/role/create',
        method: 'post',
        data
    });
}

/**
 * 删除角色
 * @param uid
 * @returns {Promise<AxiosResponse<any>>}
 */
export function removeRole(uid) {
    return request({
        url: '/sys/role/delete/' + uid,
        method: 'get'
    });
}

/**
 * 更新角色
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export function updateRole(data) {
    return request({
        url: '/sys/role/update',
        method: 'post',
        data
    });
}

/**
 * 分配权限给角色
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export function assignMenuToRole(data) {
    return request({
        url: '/sys/role/assignMenuToRole',
        method: 'post',
        data
    });
}

/**
 * 查询当前用户拥有的角色
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export function getUserRole(data) {
    return request({
        url: '/sys/role/getUserRole/' + data,
        method: 'get'
    });
}

/**
 * 分页查询
 * @param params
 * @returns {Promise<AxiosResponse<any>>}
 */
export function queryPage(params) {
    return request({
        url: '/sys/role/queryPage',
        method: 'get',
        params
    });
}

/**
 * 查询所有可用角色
 * @param params
 * @returns {Promise<AxiosResponse<any>>}
 */
export function listAllRole() {
    return request({
        url: '/sys/role/list',
        method: 'get'
    });
}
